<template>
    <div class="goods-item" @click="toDetail(goodsInfo.id)">
        <section>
            <img :src=" imgBaseUrl + goodsInfo.coverImg" alt="" class="goods-img">
            <h3 class="goods-title">{{goodsInfo.name}}</h3>
            <p class="integral">{{goodsInfo.coin}}积分</p>
            <div class="btn">立即兑换</div>
            <!-- 左上角标签  热门/新品 -->
            <img src="../../assets/img/hot-j.png" alt="" class="tip" v-if="goodsInfo.isHotSale==1">
            <img src="../../assets/img/new-j.png" alt="" class="tip" v-if="goodsInfo.isLatest==1">
        </section>
    </div>
</template>

<script>
    export default {
        props: ['goodsInfo'],
        data() {
            return {
                
            }
        },
        methods:{
            // 点击跳转至详情页
            toDetail(id){
                this.$router.push({ path:'/detail', query:{ id }})
            }
        }
    }
</script>

<style scoped lang="less">
    .goods-item {
        position: relative;
        margin-right: 20px;
        margin-bottom: 20px;
        width: 285px;
        cursor: pointer;

        section {
            width: 100%;
            padding-bottom: 30px;
            background: #fff;
            display: flex;
            flex-direction: column;
            align-items: center;
            transition: all .5s ease;

            .goods-img {
                width: 100%;
            }

            .goods-title {
                margin-top: 44px;
                font-size: 18px;
                font-family: SourceHanSansSC;
                font-weight: 300;
                color: #333333;
            }

            .integral {
                margin-top: 32px;
                font-size: 18px;
                font-family: SourceHanSansSC;
                font-weight: bold;
                color: #FD604D;
            }

            .btn {
                margin-top: 20px;
                width: 100px;
                height: 36px;
                border: 1px solid #0A328E;
                font-size: 18px;
                font-family: SourceHanSansSC;
                font-weight: 300;
                text-align: center;
                line-height: 36px;
                color: #0A328E;
            }

            .tip {
                position: absolute;
                top: 0;
                left: 0;
                width: 58px;
                height: 58px;
            }
        }

        &:hover {
            section {
                transform: translateY(-8px);
                box-shadow: 0 0 10px 0 #ccc;
            }

            .btn {
                background: #0A328E;
                color: #FFFFFF;
            }

        }

        /*  4倍数的商品不需要右外边距，如果有会位置不够从而往下走去了 */
        &:nth-of-type(4n){
            margin-right: 0;
        }
    }
</style>